<?php
//1. co_accesstoken.php
//2. pre_authcode.php    refresh pre auth code

// //http://parkson.omnimkt.com/api/co_accesstoken.php
// 
$kehuAppId='wxdf0eee3a5e4ad06a';
$get_access_token=json_decode(file_get_contents('./log/component_access_token.json'), true);
$component_access_token=$get_access_token['component_access_token'];

$appId = "wx82aa345f1fb8714b";
$data='{
"component_appid":"wx82aa345f1fb8714b" ,
"authorization_code": "auth_code_value"
}';
$res = json_decode(http_request($url, $data), true);
var_dump($res);
 


function http_request($url, $data = null)
{
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
	if (!empty($data)){
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	}
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
	$output = curl_exec($curl);
	curl_close($curl);
	return $output;
}